tic;
%------------------------------M, r, y
[nrowAeq, ncolAeq] = size(nAeq);

% check Aeq has full row rank
if rank(nAeq)==nrowAeq
    fullRowRank=true;
end

% generate random n x n non-singular matrix M
M = randi([1,10],ncolAeq);

while det(M)==0
    M = randi([1,10],ncolAeq);
end

% generate random n x 1 vector r
r = randi([1,10],ncolAeq,1);

while nbeq + nAeq * r == 0
    r = randi([1,10],ncolAeq,1);
end

% generate random integer between 1 and 50
g = round(rand(1)*49)+1;

cT = g * M' * nC;           % c' = gM'c
% cT = g * nC;
% -----------------------Q, A', b'
% generate m x m non-singular matrix Q (deteminant =/= 0)
% Q=rand(nrowAeq);
Q = randi([1,10],nrowAeq);

while det(Q)==0
    Q = randi([1,10],nrowAeq);
end

AeqT = Q * nAeq * M;                    % A' = QAM
beqT = Q * (nbeq + (nAeq * r));         % b' = Q(b + Ar)

% AeqT = Q * nAeq;                      % A' = QA
% beqT = Q * nbeq;                      % b' = Qb

%-----------------------------
% generate a random n x m lamda
[nrowAeqT, ncolAeqT] = size(AeqT);
L =randi([1,10],ncolAeqT,nrowAeqT);

AT = (nA * M) - (L * AeqT);         % B' = BM - LQAM => BM-LA' =>(A' = AeqT)
bT = (nA * r) - (L * beqT);         % 0 = Br - L(Q(b+Ar)) =>(Q(b+Ar) = beqT)
% AT = (nA - (L * nAeq));               % B' = (B - LA)
% bT = -1 * (L * nbeq);
% display transform Time
toc

tic;
% [y,fval,exitflag,output,lambda] = linprog(cT,AT,nb,AeqT,beqT);
[y,fval,exitflag] = linprog(cT,AT,nb,AeqT,beqT)
toc

% y=(y*100)/100;

% x2 = round (((M * y) - r) * 100 ) / 100;
x5 = (M * y) - r;
n=1;
nX5=[];
temp=0;

for ii=1:1:cRow
    if n <= length(cVariable)
        if ii == cVariable(n)
            if x5(ii) < 0.0001
                temp = 0;
            else
                temp = (x5(ii)*100)/100;
            end
            nX5{n,1} = ['x' num2str(ii) ' = ' num2str(temp)];
            n = n + 1;
        end
    end
end
nX5
